package com.yanqu.road.server.cmd.manor.fishpond;
import com.yanqu.road.pb.manor.FishPondProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.manor.ManorFishPondModel;
import com.yanqu.road.server.gameplayer.module.manor.ManorModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.GameProtocol;

/**
 * @author ：zfr
 * @date ：2021/10/12 11:41
 */
@Cmd(code = GameProtocol.S_FISH_POND_GET_ENERGY, desc = "鱼塘领体力")
public class GetFishPondEnergyCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        FishPondProto.GetFishPondEnergyRespMsg.Builder respMsg = FishPondProto.GetFishPondEnergyRespMsg.newBuilder();
        ManorFishPondModel manorFishPondModel = player.getModule(ManorModule.class).getManorFishPondModel();
        if (manorFishPondModel == null || manorFishPondModel.getFishPondData() == null || manorFishPondModel.getFishPondData().getFishPondLv() == 0) {
            respMsg.setRet(GameErrorCode.E_FISH_POND_IS_LOCK);
            respMsg.setRecoveryTime(0);
        } else {
            manorFishPondModel.getEnergy(respMsg);
        }
        player.sendPacket(ClientProtocol.U_FISH_POND_GET_ENERGY, respMsg);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
